Handling MCI Errors

You should always check the return value of the mciSendCommand_H60X4 function. If it indicates an error, you can use mciGetErrorStringY6KOFT to get a textual description of the error.

The following example passes the MCI error code specified by dwError to mciGetErrorString, and then displays the resulting textual error description using the MessageBox1FW7BH function.

// Uses mciGetErrorString to get a textual description of an MCI error.

// Displays the error description using MessageBox.

void showError(DWORD dwError)

    char szErrorBuf[MAXERRORLENGTH];

    MessageBeep(MB_ICONEXCLAMATION);

    if(mciGetErrorString(dwError, (LPSTR) szErrorBuf, MAXERRORLENGTH))

        MessageBox(hMainWnd, szErrorBuf, "MCI Error",

        MB_ICONEXCLAMATION);

    else

        MessageBox(hMainWnd, "Unknown Error", "MCI Error",

            MB_ICONEXCLAMATION);

}

 

 

Note  To interpret an mciSendCommand_H60X4 error return value yourself, mask the high-order word (the low-order word contains the error code). If you pass the error return value to mciGetErrorStringY6KOFT, however, you must pass the entire doubleword value.